package com.qfjg.service.imp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.qfjg.entity.PhoneList;
import com.qfjg.mappers.PhoneListMapper;
import com.qfjg.service.PhoneListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PhoneListImp extends ServiceImpl<PhoneListMapper, PhoneList> implements PhoneListService {

    @Autowired
    private PhoneListMapper phoneListMapper;

    @Override
    public void insert(PhoneList phoneList) {
        phoneListMapper.insert(phoneList);
    }

    @Override
    public boolean deleteById(String phId) {
        return phoneListMapper.deleteById(phId) > 0;

    }

    @Override
    public List<PhoneList> selectDumpRecordList(String projectId) {
        QueryWrapper<PhoneList> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("project_id", projectId);
        return phoneListMapper.selectList(queryWrapper);
    }

    @Override
    public Long selectPhoneNumber(String projectId,String phoneNumber) {
        QueryWrapper<PhoneList> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("project_id", projectId)
                .eq("phone_number", phoneNumber);
        return phoneListMapper.selectCount(queryWrapper);
    }
}
